<template>
	<el-select v-bind="$attrs" :placeholder="placeholder" filterable clearable :size="size"
			   :style="width?'width:'+width+'px;':'width:100%;'">
		<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"/>
	</el-select>
</template>
<script>
export default {
	name: "exSelect",
	components: {},
	props: {
		placeholder: {type: String, default: "请选择"},
		size: {type: String, default: "default"},//"" | "default" | "small" | "large"
		width: {type: Number, default: null},
		dictCode: {type: String, default: null},
		priKey: {type: Boolean, default: false},
		ops:{type: Array, default: null},
		permissionData:{type: Array, default: null},
	},
	data() {
		return {
			options: [],
		};
	},
	async mounted() {
		if(this.ops){
			this.options = this.ops;
		}else{
			this.options = await this.$cache.dic.options(this.dictCode, this.priKey);
		}
		if(this.permissionData&&Array.isArray(this.permissionData)&&this.options){
			this.options = this.options.filter(item=>this.permissionData.includes(item.value));
		}
	},
	methods: {}
}
</script>
